using System;
using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;
using UnityEngine.UI;


namespace AsterroidX
{
    public class UIPowerUp : BaseController
    {

        public float Seconds;

        public Text SecondsText;

        public Action OnEnd;

        public UIPowerUps UIPowerUps;


        public string PowerUpName;

        private GameModel mGameModel;
        private void Awake()
        {
            SecondsText = transform.Find("Seconds").GetComponent<Text>();

            mGameModel=this.GetModel<GameModel>();

        }

        
        private void Update()
        {
            if (!mGameModel.GameRunning) return;
                    
            Seconds -= Time.deltaTime;

            SecondsText.text = Seconds.ToString("N0");
           
            if (Seconds <= 0)
            {
                Seconds = 0;
                UIPowerUps.Remove(PowerUpName);
                OnEnd?.Invoke();

              
               

                this.DestroyGameObj();

            }

        }
    }
}

